package com.stu.day15;

import java.io.*;

/**
 * @author zy
 * @date 2025/2/13 19:43
 */
public class BufferdeByteDemo {
    public static void main(String[] args) {
        try(BufferedInputStream in = new BufferedInputStream(new FileInputStream("src/com/stu/day15/demo1.png"));
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("src/com/stu/day15/demo1_副本.png"))) {

            //自定义一个缓冲区
            byte[] buf = new byte[3*1024];
            while(true){
                int len = in.read(buf);
                if(len==-1)
                    break;
                out.write(buf,0,len);
            }
            System.out.println("复制成功!");

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
